/**
 */
package mvc_generator.mVCGenerator.impl;

import java.util.Collection;

import mvc_generator.mVCGenerator.Condition;
import mvc_generator.mVCGenerator.FormValidation;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;
import mvc_generator.mVCGenerator.View;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Form Validation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.FormValidationImpl#getValidatedFormName <em>Validated Form Name</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.FormValidationImpl#getConditions <em>Conditions</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.FormValidationImpl#getViewsOnSuccess <em>Views On Success</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FormValidationImpl extends MinimalEObjectImpl.Container implements FormValidation
{
  /**
   * The default value of the '{@link #getValidatedFormName() <em>Validated Form Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatedFormName()
   * @generated
   * @ordered
   */
  protected static final String VALIDATED_FORM_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getValidatedFormName() <em>Validated Form Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatedFormName()
   * @generated
   * @ordered
   */
  protected String validatedFormName = VALIDATED_FORM_NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getConditions() <em>Conditions</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConditions()
   * @generated
   * @ordered
   */
  protected EList<Condition> conditions;

  /**
   * The cached value of the '{@link #getViewsOnSuccess() <em>Views On Success</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getViewsOnSuccess()
   * @generated
   * @ordered
   */
  protected EList<View> viewsOnSuccess;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FormValidationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.FORM_VALIDATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getValidatedFormName()
  {
    return validatedFormName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValidatedFormName(String newValidatedFormName)
  {
    String oldValidatedFormName = validatedFormName;
    validatedFormName = newValidatedFormName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME, oldValidatedFormName, validatedFormName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Condition> getConditions()
  {
    if (conditions == null)
    {
      conditions = new EObjectContainmentEList<Condition>(Condition.class, this, MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS);
    }
    return conditions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<View> getViewsOnSuccess()
  {
    if (viewsOnSuccess == null)
    {
      viewsOnSuccess = new EObjectResolvingEList<View>(View.class, this, MVCGeneratorPackage.FORM_VALIDATION__VIEWS_ON_SUCCESS);
    }
    return viewsOnSuccess;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS:
        return ((InternalEList<?>)getConditions()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        return getValidatedFormName();
      case MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS:
        return getConditions();
      case MVCGeneratorPackage.FORM_VALIDATION__VIEWS_ON_SUCCESS:
        return getViewsOnSuccess();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        setValidatedFormName((String)newValue);
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS:
        getConditions().clear();
        getConditions().addAll((Collection<? extends Condition>)newValue);
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__VIEWS_ON_SUCCESS:
        getViewsOnSuccess().clear();
        getViewsOnSuccess().addAll((Collection<? extends View>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        setValidatedFormName(VALIDATED_FORM_NAME_EDEFAULT);
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS:
        getConditions().clear();
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__VIEWS_ON_SUCCESS:
        getViewsOnSuccess().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        return VALIDATED_FORM_NAME_EDEFAULT == null ? validatedFormName != null : !VALIDATED_FORM_NAME_EDEFAULT.equals(validatedFormName);
      case MVCGeneratorPackage.FORM_VALIDATION__CONDITIONS:
        return conditions != null && !conditions.isEmpty();
      case MVCGeneratorPackage.FORM_VALIDATION__VIEWS_ON_SUCCESS:
        return viewsOnSuccess != null && !viewsOnSuccess.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (validatedFormName: ");
    result.append(validatedFormName);
    result.append(')');
    return result.toString();
  }

} //FormValidationImpl
